const router = require("koa-router")();
const MoviesModel = require("../../models/movie");
router.get("/api/moviesDetail",async ctx=>{
    var {id} = ctx.query;
    var table = ["top250","inTheaters","comingSoon"];
    var result = [];
    for(let key of table){
        let res = await MoviesModel(key).find({_id:id})
        result.push(...res);
    }
    if(result.length==0){
        ctx.body = {
            code:200,
            msg:`未搜索到关键字！666`
        }
    }else{
        ctx.body = {
            code:200,
            result,
            msg:`搜索成功！搜索到${result.length}条数据。`
        }
    }
    
})
module.exports = router;